package com.example.yiqiuser.service.impl;

import com.example.yiqiuser.dao.TDicAreaDao;

import com.example.yiqiuser.entity.TDicArea;
import com.example.yiqiuser.service.TDicAreaService;
import com.example.yiqiuser.util.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @program: yiqiuser
 * @description:
 * @author: 诸葛龙辰
 * @create: 2023-04-06 10:46
 * @version:
 **/
@Service
public class TDicAreaServiceImpl implements TDicAreaService {
    /**
     * 依赖注入
     */
    @Resource
    private TDicAreaDao tDicAreaDao;
    /**
     * 分页查询
     * @param page
     * @return
     */
    @Override
    public PageInfo queryPage(Page<TDicArea> page) {
        PageHelper.startPage(page.getPageNo(), page.getPageSize());
        return new PageInfo(tDicAreaDao.queryByParam(page.getData()));
    }

    /**
     * 查询所有
     * @return
     */
    @Override
    public List<TDicArea> queryAll() {
        return tDicAreaDao.queryAll();
    }

    /**
     * 根据id查询
     * @param code
     * @return
     */
    @Override
    public TDicArea queryById(Integer code) {
        List<TDicArea> tDicAreaList = tDicAreaDao.queryById(code);
        if (tDicAreaList!=null&&tDicAreaList.size()>0){
            return tDicAreaList.get(0);
        }
        return null;
    }

    /**
     * 添加
     * @param tDicArea
     * @return
     */
    @Override
    public int add(TDicArea tDicArea) {
        return tDicAreaDao.add(tDicArea);
    }

    /**
     * 更改
     * @param tDicArea
     * @return
     */
    @Override
    public int update(TDicArea tDicArea) {
        return tDicAreaDao.update(tDicArea);
    }

    /**
     * 根据id删除
     * @param code
     * @return
     */
    @Override
    public int deleteById(Integer code) {
        return tDicAreaDao.deleteById(code);
    }
}
